<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWorkflowV2Orders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('workflow_v2_orders', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0)->comment('');
            $table->string('workflowNo')->default('')->comment('流水号');
            $table->unsignedInteger('relationId')->default(0)->comment('关联业务的主表id');
            $table->string('name', 32)->default('')->comment('模板名称');
            $table->unsignedTinyInteger('workflowType')->default(0)->comment('工作流类型 1续签 99其他');
            $table->unsignedTinyInteger('workflowType2')->default(0)->comment('工作流类型 1续签 99其他');
            $table->unsignedTinyInteger('status')->default(0)->comment('0进行中 1完成 2关闭');
            $table->unsignedInteger('submitCruiseTemplateId')->default(0)->comment('提交表单id');
            $table->unsignedInteger('submitCruiseOrderId')->default(0)->comment('提交表单实例化cruiseOrder.id');
            $table->unsignedInteger('currentNodeId')->default(0)->comment('当前节点id workflow_v2_order_nodes.id');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->tinyInteger('isDeleted')->default(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '审批流v2 - 订单表';

            $table->index('shopId', 'idx_shopId');
            $table->index('relationId', 'idx_relationId');
            $table->index('workflowNo', 'idx_workflowNo');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('workflow_v2_orders');
    }
}
